module.exports = function(app, passport, authUtil) {
	// frontend routes =========================================================
	// route to handle all angular skeleton template requests

	//show the login form
	app.get('/login', function(req, res) {
		// render the page and pass in any flash data if it exists
		res.render('login.ejs', { message: req.flash('loginMessage') });
	});

	app.get('/profile', function(req, res) {
		// render the page and pass in any flash data if it exists
		res.render('profile.ejs', {
			user : req.user // get the user out of session and pass to template
		});
	});

	// process user login
	app.post('/login', passport.authenticate('local-login', {
		successRedirect : '/dashboard', // redirect to the secure profile section
		failureRedirect : '/login', // redirect back to the signup page if there is an error
		failureFlash : true // allow flash messages
	}));

	// show the signup form
	app.get('/signup', function(req, res) {
		// render the page and pass in any flash data if it exists
		res.render('signup.ejs', { message: req.flash('signupMessage') });
	});

	app.post('/signup', passport.authenticate('local-signup', {
		successRedirect : '/dashboard', // redirect to the secure profile section
		failureRedirect : '/signup', // redirect back to the signup page if there is an error
		failureFlash : true // allow flash messages
	}));

	app.get('/dashboard', authUtil.isLoggedIn, function(req, res) {
		res.render('dashboard.ejs', {
			user : req.user // get the user out of session and pass to template
		});
	});

	//process user logout
	app.get('/logout', authUtil.isLoggedIn, function(req, res) {
		req.logout();
		res.redirect('/');
	});

	app.get('/', function(req, res) {
		res.render('index.ejs');
	});

};